class Solution:
    def convert(self, s: str, numRows: int) -> str:
        if numRows < 2: return s
        res = ["" for _ in range(numRows)]
        i, flag = 0, -1
        for char in s:
            res[i] += char
            if i == 0 or i == numRows - 1: flag = -flag
            i += flag
        # 因为输出的是一行所以需要join一下所有的字符串
        return "".join(res)
'''
两头都需要转弯
'''
